/* eslint-disable */
import Vue from 'vue'
const PopperJS = Vue.prototype.$isServer ? function() {} : require('./popper')
export default {
  props: {
    value: Boolean
  },
  data() {
    return {}
  },
  methods: {
    createPopper() {
      const options = this.popperOptions
      const popper = (this.popperElm =
        this.popperElm || this.popper || this.$refs.popper)
      let reference = (this.referenceElm =
        this.referenceElm || this.reference || this.$refs.reference)
      this.popperJS = new PopperJS(reference, popper, options)
      this.popperJS.onCreate((_) => {
        this.$emit('created', this)
        this.resetTransformOrigin()
      })
      if (this.appendToBody) {
        document.body.appendChild(this.popperElm)
      }
    },
    resetTransformOrigin() {
      if (!this.transformOrigin) {
        return
      }
      let placementMap = {
        top: 'bottom',
        bottom: 'top',
        left: 'right',
        right: 'left'
      }
      let placement = this.popperJS._popper.getAttribute('x-placement').split('-')[0];
      let origin = placementMap[placement];
      this.popperJS._popper.style.transformOrigin = typeof this.transformOrigin === 'string'
        ? this.transformOrigin
        : ['top', 'bottom'].indexOf(placement) > -1 ? `center ${ origin }` : `${ origin } center`;
    },
    updatePopper() {
      let popperJS = this.popperJS
      if (popperJS) {
        console.error('234w')
      } else {
        this.createPopper()
      }
    }
  },
  mounted() {}
}
